<template>
    <div class="write-remark">
        <nut-form>
            <nut-form-item label="手机号">
                <nut-input v-model="phone" class="nut-input-text" placeholder="请输入手机号" type="text" />
            </nut-form-item>
            <nut-form-item label="意见">
                <nut-textarea placeholder="请输入意见" type="text" v-model="remark" />
            </nut-form-item>
        </nut-form>
        <div class="save-remark">
            <nut-button shape="square" color="#8DCF00" type="info" @click="saveRemark">保存</nut-button>
        </div>
    </div>
</template>

<script lang="ts">
import Taro, { useRouter } from '@tarojs/taro';
import { } from '@nutui/icons-vue-taro';
import { reactive, toRefs, onMounted } from 'vue';
import { toFeedBack } from '../../../../api/index'
export default {
    components: {

    },
    setup() {
        const data = reactive({
            remark: '',
            phone: ''
        });


        const saveRemark = () => {
            toFeedBack({ remark: data.remark, phone: data.phone }).then(res => {
                //console.log(res)
                if (res.resultCode == 200) {
                    Taro.showToast({
                        title: '提交成功！',
                        icon: 'success',
                        duration: 2000
                    })
                }
            })
        }
        onMounted(() => {
            Taro.getStorage({
                key: 'user',
                success: function (res) {
                    data.phone = res.data.phone
                }
            })
        });

        return {
            ...toRefs(data), saveRemark
        }
    }
};
</script>


<style lang="scss">
.write-remark {
    .nut-cell {
        .nut-cell {
            padding: 0;
        }
    }
}

.save-remark {
    position: fixed;
    bottom: 0;
    left: 0;
    background: #fff;
    padding: 20rpx 40rpx;
    box-sizing: border-box;
    width: 100%;
    text-align: center;

    .nut-button {
        width: 400rpx;
        margin: 0 auto;
        border-radius: 10rpx;
    }
}
</style>